/*
 * Copyright (C) 2020 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;

import com.xuexiang.templateproject.R;
import com.xuexiang.templateproject.adapter.entity.Message;
import com.xuexiang.templateproject.adapter.entity.NewInfo;
import com.xuexiang.templateproject.adapter.entity.Talk;
import com.xuexiang.xaop.annotation.MemoryCache;
import com.xuexiang.xui.adapter.simple.AdapterItem;
import com.xuexiang.xui.utils.ResUtils;
import com.xuexiang.xui.widget.banner.widget.banner.BannerItem;

import java.util.ArrayList;
import java.util.List;

/**
 * 演示数据
 *
 * @author xuexiang
 * @since 2018/11/23 下午5:52
 */
public class DemoDataProvider {

    public static String[] titles = new String[]{
            "伪装者:胡歌演绎'痞子特工'",
            "无心法师:生死离别!月牙遭虐杀",
            "花千骨:尊上沦为花千骨",
            "综艺饭:胖轩偷看夏天洗澡掀波澜",
            "碟中谍4:阿汤哥高塔命悬一线,超越不可能",
    };

    public static String[] urls = new String[]{//640*360 360/640=0.5625
            "https://i.ibb.co/9Gqmd1n/pic-main-5.jpg",
            "https://i.ibb.co/sgLXQpd/pic-main-1.jpg",//伪装者:胡歌演绎"痞子特工"
            "https://i.ibb.co/cCpjrvH/pic-main-2.jpg",//无心法师:生死离别!月牙遭虐杀
            "https://i.ibb.co/CH2P60N/pic-main-3.jpg",//花千骨:尊上沦为花千骨
            "https://i.ibb.co/rZcs77L/pic-main-4.jpg"//综艺饭:胖轩偷看夏天洗澡掀波澜

    };

    @MemoryCache
    public static List<BannerItem> getBannerList() {
        List<BannerItem> list = new ArrayList<>();
        for (int i = 0; i < urls.length; i++) {
            BannerItem item = new BannerItem();
            item.imgUrl = urls[i];
            item.title = titles[i];
            list.add(item);
        }
        return list;
    }

    /**
     * 用于占位的空信息
     *
     * @return
     */
    @MemoryCache
    public static List<NewInfo> getDemoNewInfos() {
        List<NewInfo> list = new ArrayList<>();
        NewInfo newInfo = new NewInfo();
        newInfo.setAuthor("工作室");
        newInfo.setImg("https://img.zcool.cn/community/01f4805ef320fba801215aa05a5795.jpg@260w_195h_1c_1e_1o_100sh.jpg");
        newInfo.setID("111234");
        newInfo.setNum(33);
        newInfo.setPrice(66);
        newInfo.setType("绘画");
        list.add(newInfo);
        list.add(newInfo);
        return list;
    }

    public static List<AdapterItem> getGridItems(Context context) {
        return getGridItems(context, R.array.grid_titles_entry, R.array.grid_icons_entry);
    }


    private static List<AdapterItem> getGridItems(Context context, int titleArrayId, int iconArrayId) {
        List<AdapterItem> list = new ArrayList<>();
        String[] titles = ResUtils.getStringArray(titleArrayId);
        Drawable[] icons = ResUtils.getDrawableArray(context, iconArrayId);
        for (int i = 0; i < titles.length; i++) {
            list.add(new AdapterItem(titles[i], icons[i]));
        }
        return list;
    }

    @MemoryCache
    public static List<Talk> getTalkInfo() {
        List<Talk> list = new ArrayList<>();
        Talk talk = new Talk();
        talk.setImgUrl("http://img.mp.itc.cn/upload/20170724/cf678e09eb384401aa616ba134126357_th.jpg");
        talk.setAuthor("ICY");
        talk.setFocus("关注");
        talk.setContent("今天好开心");
        list.add(talk);
        list.add(talk);
        return list;
    }

    @MemoryCache
    public static List<Message> getMessageInfo() {
        List<Message> list = new ArrayList<>();
        Message message = new Message();
        message.setImgId(R.drawable.ic_talk_head1);
        message.setAuthor("YD-01");
        message.setContent("hello!");
        message.setMessageNum(2);
        list.add(message);
        message = new Message();
        message.setImgId(R.drawable.ic_message_head1);
        message.setAuthor("YD-02");
        message.setContent("哈哈哈");
        message.setMessageNum(1);
        list.add(message);
        return list;
    }
}
